<html>
<head><meta charset="utf-8"><title>Symbols from the dynamic libraries · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html">Symbols from the dynamic libraries</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232190961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232190961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232190961">(Mar 28 2021 at 20:28)</a>:</h4>
<p>Do we have a good unified way to tell if a declaration would come from a dynamic library? (i.e. <code>#[link(kind="various dynamic options"]</code> on an extern block, shared generics from dynamic <code>--extern</code> libraries etc.)</p>



<a name="232193212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232193212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232193212">(Mar 28 2021 at 21:05)</a>:</h4>
<p>No, only the linker knows which symbol is defined where.</p>



<a name="232193951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232193951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232193951">(Mar 28 2021 at 21:18)</a>:</h4>
<p>My understanding from issues such as <a href="https://github.com/rust-lang/rust/issues/65610">https://github.com/rust-lang/rust/issues/65610</a> is that rustc must have knowledge which symbols come from what libraries. Otherwise it'll fail to correctly order the linker arguments or make public certain symbols or declarations.</p>



<a name="232194893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232194893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232194893">(Mar 28 2021 at 21:34)</a>:</h4>
<p>At least for some of them.</p>



<a name="232200161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232200161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232200161">(Mar 28 2021 at 23:14)</a>:</h4>
<p>I think there is such an association by <code>#[link]</code> as you say, and also at the crate level with a build script emitting <code>rustc-link-lib</code>, but the linker is not bound by any of that</p>



<a name="232200267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232200267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232200267">(Mar 28 2021 at 23:16)</a>:</h4>
<p>The reason why I am asking this is because I'm looking for opportunities to add <code>dso_local</code> annotations. I tried adapting the logic clang has for this, but that logic doesn't really work at all for the purposes of Rust.</p>



<a name="232200281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232200281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232200281">(Mar 28 2021 at 23:16)</a>:</h4>
<p>primarily hitting cases like rust pulling in definitions of generic monomorphizations in other crates.</p>



<a name="232230281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232230281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232230281">(Mar 29 2021 at 07:50)</a>:</h4>
<blockquote>
<p>The reason why I am asking this is because I'm looking for opportunities to add dso_local annotations.</p>
</blockquote>
<p>Doesn't LLVM adds them automatically based on visibilities, etc?<br>
I remember reading that code when documenting TLS models (LLVM can chose a more optimal TLS model for DSO local symbols), and the DSO local property was calculated from many inputs, IIRC.</p>



<a name="232251682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232251682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232251682">(Mar 29 2021 at 11:19)</a>:</h4>
<p>Apparently not anymore. In llvm 12 some of that logic was moved away from llvm into clang which broke some of the users.</p>



<a name="232252067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Symbols%20from%20the%20dynamic%20libraries/near/232252067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Symbols.20from.20the.20dynamic.20libraries.html#232252067">(Mar 29 2021 at 11:23)</a>:</h4>
<p>It's also no longer just a hint contrary to what langref claims it seems.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>